package com.yiwei.ydd.view;

import android.app.Dialog;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.yiwei.ydd.R;
import com.yiwei.ydd.activity.OilCardAddActivity;
import com.yiwei.ydd.adapter.BankCardChangeAdapter;
import com.yiwei.ydd.adapter.OilChangeAdapter;
import com.yiwei.ydd.util.Util;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * Created by xsooy-pc on 2017/4/24.
 */

public class ChangeBankCardDialog extends Dialog {


    @BindView(R.id.list)
    RecyclerView list;
    @BindView(R.id.layout_add_new)
    RelativeLayout layoutAddNew;
    private Context context;
    private BankCardChangeAdapter adapter;

    public ChangeBankCardDialog(Context context) {
        this(context, R.style.DialogStyle);
    }

    public ChangeBankCardDialog(Context context, int themeResId) {
        super(context, themeResId);
        this.context = context;
        initView();
    }

    private void initView() {
        setContentView(R.layout.dialog_change_bankcard);
        ButterKnife.bind(this);
        setCancelable(false);

        Window mWindow = getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        lp.width = (int) (Util.getDisplayMetrics(context).widthPixels * 0.85);
        mWindow.setAttributes(lp);

        adapter = new BankCardChangeAdapter(context);
        adapter.setOnChooseListener(new BankCardChangeAdapter.OnChooseListener() {
            @Override
            public void onClick(String name) {
                dismiss();
            }
        });
        list.setAdapter(adapter);
        List<String> data = new ArrayList<>();
        data.add("dadsa");
        data.add("dadsa");
        data.add("dadsa");
        data.add("dadsa");
        data.add("dadsa");
        data.add("dadsa");
        adapter.update(data);
    }


    public void setData() {
//        adapter.update();
    }


    private DialogDefaultClickListener listener;

    public void setDialogClickListener(DialogDefaultClickListener listener) {
        this.listener = listener;
    }

    @OnClick(R.id.layout_add_new)
    public void onViewClicked() {
        Util.startActivity(context, OilCardAddActivity.class);
    }


    public interface DialogDefaultClickListener {
        public abstract void confirm();

        public abstract void cancel();
    }
}
